class Amount < ActiveRecord::Base
  belongs_to :currency, :primary_key => :code, :foreign_key => :currency_code
  belongs_to :wallet

  validates_presence_of :wallet
  validates_presence_of :currency_code
  validates_uniqueness_of :currency_code, :scope => :wallet_id

  def currency
    @currency ||= Currency.find_by_code(currency_code)
  end

end
